﻿package mortal.game.view.guild
{
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.guide.*;
    import mortal.game.view.guild.tabpanel.*;
    import mortal.game.view.wizard.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildModule extends BaseWindow
    {
        public var _curPanel:GuildBasePanel = null;
        private var _tabBar:GTabarNew = null;
        private var _tabData:Array = null;
        private var _panelClassList:Vector.<Class> = null;
        protected var _redBtn:GButton;

        public function GuildModule(param1:ILayer = null)
        {
            super(param1);
            setSize(732, 533);
            title = "" + Language.getString(71340);
            titleHeight = 60;
            return;
        }// end function

        override protected function configUI() : void
        {
            this._tabData = Language.getArray(60002);
            this._panelClassList = new Vector.<Class>;
            this._panelClassList.push(GuildInfoPanel);
            this._panelClassList.push(GuildMembersPanel);
            this._panelClassList.push(GuildBuildingPanel);
            this._panelClassList.push(GuildSkillPanel);
            this._panelClassList.push(GuildBustlingPanel);
            super.configUI();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._redBtn = UIFactory.gButton("", 253, 32, 80, 27, this);
            this._redBtn.mouseEnabled = false;
            this._tabBar = UIFactory.gTabBarNew(0, 32, this._tabData, 733, 570, 80, 26, this, this.onTabBarChange, "TabButtonNew");
            this._tabBar.selectedIndex = 0;
            this.onTabBarChange();
            Dispatcher.addEventListener(EventName.AutoGuideRedPointRefresh, this.onAutoGuideRedPointRefresh);
            return;
        }// end function

        private function onAutoGuideRedPointRefresh(event:DataEvent = null) : void
        {
            var _loc_2:GLoadedButton = null;
            if (AutoGuideRedPoint2.instance.getValueByName(AutoGuideRedPoint2.GuildSkillLvUp))
            {
                if (this._tabBar.selectedIndex != 3)
                {
                    EffectManager.glowFilterReg(this._redBtn, [FilterConst.chatTipsFilter], 0.6, 20, 2, 0);
                }
            }
            else
            {
                EffectManager.glowFilterUnReg(this._redBtn);
            }
            if (AutoGuideRedPoint.instance.getValueByName(AutoGuideRedPoint.GuildGodTree))
            {
                if (this._curPanel is GuildInfoPanel)
                {
                    _loc_2 = (this._curPanel as GuildInfoPanel).iconGuildGodTree;
                    EffectManager.glowFilterReg(_loc_2, [FilterConst.chatTipsFilter], 0.6, 20, 2, 0);
                }
            }
            else if (this._curPanel is GuildInfoPanel)
            {
                _loc_2 = (this._curPanel as GuildInfoPanel).iconGuildGodTree;
                EffectManager.glowFilterUnReg(_loc_2);
            }
            return;
        }// end function

        protected function onTabBarChange(event:Event = null) : void
        {
            if (AutoGuideController._guidingMainId == 25)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStopCurStep, [25]));
            }
            if (this._tabBar.selectedIndex >= this._panelClassList.length)
            {
                return;
            }
            if (this._curPanel is this._panelClassList[this._tabBar.selectedIndex])
            {
                return;
            }
            if (this._panelClassList[this._tabBar.selectedIndex] == GuildMembersPanel)
            {
                this._curPanel.dispose();
                this._curPanel = UICompomentPool.getUICompoment(GuildMembersPanel, 0);
                GuildMembersPanel(this._curPanel).listType = 0;
                this.addChild(this._curPanel);
                this.onAutoGuideRedPointRefresh();
                return;
            }
            if (this._curPanel)
            {
                this._curPanel.dispose();
            }
            this._curPanel = UICompomentPool.getUICompoment(this._panelClassList[this._tabBar.selectedIndex]);
            this.addChild(this._curPanel);
            this.onAutoGuideRedPointRefresh();
            if (this._tabBar.selectedIndex == 3)
            {
                EffectManager.glowFilterUnReg(this._redBtn);
            }
            return;
        }// end function

        public function update(param1:Class = null) : void
        {
            if (this._curPanel == null)
            {
                return;
            }
            if (this._curPanel.visible == false)
            {
                return;
            }
            if (param1 == null || this._curPanel is param1)
            {
                if (this._curPanel.isLoadComplete)
                {
                    this._curPanel.update();
                }
            }
            return;
        }// end function

        public function changeTab(param1:int) : void
        {
            this._tabBar.selectedIndex = param1;
            this.onTabBarChange(null);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            Dispatcher.removeEventListener(EventName.AutoGuideRedPointRefresh, this.onAutoGuideRedPointRefresh);
            AutoGuideRedPoint2.instance.setValueByName(AutoGuideRedPoint2.GuildSkillLvUp, false);
            AutoGuideRedPoint.instance.setValueByName(AutoGuideRedPoint.GuildGodTree, false);
            this._tabBar.dispose();
            this._tabBar = null;
            if (this._curPanel)
            {
                this._curPanel.dispose();
            }
            this._curPanel = null;
            this._redBtn.dispose(param1);
            this._redBtn = null;
            return;
        }// end function

    }
}
